//
//  ScrollViewCollectionReusableView.m
//  OneCreditTreasure
//
//  Created by iOS Grouper on 16/8/26.
//
//

#import "ScrollViewCollectionReusableView.h"
#import "YYCycleScrollView.h"
@implementation ScrollViewCollectionReusableView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        YYCycleScrollView *cycleScrollView = [[YYCycleScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, self.frame.size.height) animationDuration:2.0];
        [self addSubview:cycleScrollView];
NSMutableArray *viewArray = [[NSMutableArray alloc] init];
        for (int i = 0; i < 5; i++) {
            UIImageView *tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
            
            
            tempImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",i+1]];
            tempImageView.contentMode = UIViewContentModeScaleAspectFill;
            tempImageView.clipsToBounds = true;
            [viewArray addObject:tempImageView];
            cycleScrollView.backgroundColor = [UIColor redColor];
        }
        
        [cycleScrollView setFetchContentViewAtIndex:^UIView *(NSInteger(pageIndex)) {
            return [viewArray objectAtIndex:pageIndex];
        }];
        [cycleScrollView setTotalPagesCount:^NSInteger{
            return 5;
        }];
        [cycleScrollView setTapActionBlock:^(NSInteger(pageIndex)) {
            
            NSLog(@"点击的相关的页面%ld",(long)pageIndex);
            
        }];
        

    }
    return self;
}
@end
